<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Title</title>
    <style>
        #content {
            background-color: #eeeeee;
        }
    </style>
</head>
<body>
    <input oninput="getAutoCompletedHints(this)">
    <div id="content">
    </div>

    <script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
    <script>
        var content = document.getElementById('content');

        function getAutoCompletedHints(inputDom) {
            // console.log(inputDom.value);
            var prefix = inputDom.value;
            if (prefix.trim()) {
                content.innerHTML = '';

                $.getJSON("http://forum.com/cli/auto-complete?prefix=" + prefix.trim(), {},
                function (_data) {
                    for (var i = 0; i < _data.length; i++) {
                        var pTag = document.createElement('p');
                        pTag.innerText = _data[i];
                        content.appendChild(pTag);
                    }
                });
            }
        }
    </script>
</body>
</html>